<?php
	require("../Model/mysql.php");
	require('../host_config.php');
	session_start();
	error_reporting(E_ALL);
	if (!isset($_SESSION['username'])) {
        echo "<script language='javascript'>";
        echo "alert('You have no permission to read this page!');";
        echo "history.back();";
        echo "</script>";
        header("location:../login.php");
	}else {

		$mysql = new MySQL();
		$link = $mysql->connect($mysql_host, $mysql_user, $mysql_passwd, $mysql_db);
		//$result = mysql_query("SELECT all_name FROM android", $link);
		$result = mysql_query("SELECT fullname FROM Shops", $link);
		while ($row = mysql_fetch_assoc($result)) {
   			$colors[]=$row['fullname'];
		}
		$part = $_GET['part'];
		$part = mysql_real_escape_string($part);
		if(isset($part) and $part != '')
		{
			// initialize the results array
			$results = array();

			// search colors
			foreach($colors as $color)
			{
				// if it starts with 'part' add to results
				if( strpos($color, $_GET['part']) === 0 ){
					$results[] = $color;
				}
			}

			// return the array as json with PHP 5.2
			echo json_encode($results);
		}
	}
?>
